<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/user_register.css">
    <script src="js/jquery.min.js"></script>
</head>

<body>
    <div class="nav">弈- 多人在线五子棋pk系统</div>
    <div class="login">
        <div class="login-box">
        <h3>用户注册</h3>
        <div class="row">
            <span>用户名:</span>
            <input type="text" id="userName">
        </div>
        <div class="row">
            <span>密码</span>
            <input type="password" id="password">
        </div>
        <div class="row">
            <button id="submit"  onclick="register()">注册</button>
        </div>
        </div>
    </div>

    
    <script>
        
        function register(){
            $.ajax({
                url:"/user/register",
                type:"post",
                data:{
                    userName:$("#userName").val(),
                    password:$("#password").val()
                },
                success:function(data){
                    
                    if(data.code == "SUCCESS" && data.data=="注册成功"){
                        alert("注册成功");
                        location.href="login.html"
                    }else{
                        alert(data.errMsg);
                    }
                    
                },
                error:function(data){
                    alert(data.errMsg);
                }
            })
        }
    </script>
    
</body>
</html>